PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Using it, me, and my in Tell Statements

AppleScript defines the variables it and me for use in Tell statements. It also defines the word my , which you can use in place of the phrase of me .

The variable it is the default target. The value of it is a reference, as in

tell document "Introduction" of application "AppleWorks"
    get name of it --result: "Introduction"
end tell

The value of the variable it is document "Introduction" of application "AppleWorks" . The result of the Get command is the string "Introduction" .

The variable me refers to the current script, as in the following example. The line that specifies the property name could be placed at the end of the script as well as at the beginning.

property name : "Script"
tell document "Introduction" of application "AppleWorks"
    get name of me --result: "Script"
end tell

The reference name of me refers to the name property of the current script. The result of the Get command is the string "Script" .

The following script, which is equivalent to the previous example, uses the word my as an alternative to of me .

property name : "Script"
tell document "Introduction" of application "AppleWorks"
    get my name --result: "Script"
end tell

If you refer to a property in a Tell statement without using either it , me , or my , AppleScript assumes that you want the property of the default target of the Tell statement. For example, the result of the Get command in the following Tell statement is "Introduction" .

property name : "Script"
tell document "Introduction" of application "AppleWorks"
    get name --result: "Introduction"
end tell

If AppleScript cannot find the property in the dictionary of the default target of the Tell statement, then it assumes you want the property of the current script. For example, the result of the Get command in the following Tell statement is 1000000 .

property x : 1000000
tell document "Introduction" of application "AppleWorks"
    get x --result: 1000000
end tell

In addition to distinguishing script properties from object properties, me and my are used to distinguish user-defined commands (subroutines) from application commands in Tell statements. For more information, see Handlers

Note

Within tests in Filter references, the direct object is the object being tested, so the variable it refers to the object currently being tested. See Using the Filter Reference Form for information about the use of it in tests.


© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)